//
//  InformationTableViewCell.m
//  Rail
//
//  Created by hychen on 2018/2/27.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "InformationTableViewCell.h"

@interface InformationTableViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *warnIcon;
@property (weak, nonatomic) IBOutlet UILabel *warnTitle;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;
@property (weak, nonatomic) IBOutlet UILabel *handleLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@end
@implementation InformationTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.titleLabel.font = SCREEN_WIDTH<375?[UIFont systemFontOfSize:15]:[UIFont systemFontOfSize:16];
    [self showArrowWithImage:nil];
    [self showBottomLineWithPaddingX:15 color:nil];
    
}

//- (void)setModel:(InformationEventModel *)model {
//    _model = model;
//    [self setWarnStyle:model.event_level];
//    [self setHandleResultStyle:[model.process_result integerValue]];
//
//    self.titleLabel.text = model.event_name;
//    self.contentLabel.text = model.content;
//}

- (void)setEventModel:(InformationEventModel *)eventModel {
    _eventModel = eventModel;
    
}

- (void)setModel:(WarnDetailModel *)model {
    _model = model;

    [self setWarnStyle:model.event_level];
    [self setHandleResultStyle:[model.process_result integerValue]];

    self.titleLabel.text = [NSString stringWithFormat:@"%@%@%@",model.line_name,model.area_name,[WarnLevelConfig alertTypeStringWithType:model.alert_type]];
    self.contentLabel.text = model.content;
    
}

- (void)setHandleResultStyle:(HandleResult)type {
    switch (type) {
        case HandleResultTodo:
        {
            self.handleLabel.text = @"未处理";
            self.handleLabel.textColor = Color_RGB(255, 159, 7);
            self.timeLabel.text = [BMUtils chineseMMDDHHmmWithServiceTime:self.model.start_time];
            break;
        }
        case HandleResultDone:
        {
            self.handleLabel.text = @"已处理";
            self.handleLabel.textColor = Color_RGB(7, 119, 255);
            self.timeLabel.text = [BMUtils chineseMMDDHHmmWithServiceTime:self.model.process_time];
            break;
        }
        default:
            break;
    }
}

- (void)setWarnStyle:(WarnLevelType)type {
    switch (type) {
        case WarnLevelTypeNormal:
        {
            self.warnIcon.image = [UIImage imageNamed:@"information_general_warn_ic"];
            self.warnTitle.textColor = Color_RGB(255, 200, 7);
            self.warnTitle.text = @"普通";
            break;
        }
        case WarnLevelTypeWarn:
        {
            self.warnIcon.image = [UIImage imageNamed:@"information_common_warn_ic"];
            self.warnTitle.textColor = Color_RGB(255, 159, 7);
            self.warnTitle.text = @"警告";
            break;
        }
        case WarnLevelTypeSerious:
        {
            self.warnIcon.image = [UIImage imageNamed:@"information_severity_warn_ic"];
            self.warnTitle.textColor = Color_RGB(255, 122, 0);
            self.warnTitle.text = @"严重";
            break;
        }
        case WarnLevelTypeHeavy:
        {
            self.warnIcon.image = [UIImage imageNamed:@"information_great_warn_ic"];
            self.warnTitle.textColor = Color_RGB(255, 30, 0);
            self.warnTitle.text = @"重大";
            break;
        }
        default:
            break;
    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
